package com.own.demo.lwf.threadTest;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @version v1.0
 * @Description:java练习
 * @Author 李文峰
 * @Date 2023/4/30 0030 17:16
 */
public class TestCreateThreadByFutureTask {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> ft = new FutureTask<>(new Callable<String>() {
            @Override
            public String call() throws Exception {
                return "测试0";
            }
        });
        // Lambdab表达式
        FutureTask<String> ft1 = new FutureTask<String>(() -> "测试1");

        new Thread(ft).start();
        new Thread(ft1).start();
        System.out.println("执行结果：" + ft.get());
        System.out.println("执行结果：" + ft1.get());

    }
}
